package com.cskaoyan.app.wxcontroller;

import com.cskaoyan.app.bean.common.BaseRespVo;
import com.cskaoyan.app.bean.vo.wx.IndexOrderVO;
import com.cskaoyan.app.wxservice.WxIndexService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("wx/user")
public class WxUserController {

    @Autowired
    private WxIndexService indexService;

    @GetMapping("index")
    public BaseRespVo<IndexOrderVO> index() {
        Subject subject = SecurityUtils.getSubject();
        Integer userid = (Integer) subject.getSession().getAttribute("userid");
        Map<String, Long> indexMap = indexService.getIndexMap(userid);
        return BaseRespVo.ok(new IndexOrderVO(indexMap));
    }
}
